﻿package lz.controls.scroll
{
    import flash.display.*;
    import flash.events.*;

    public class SliderBar 
	{

        private var LIST:Array;

        private var _sliderBar:MovieClip = null;
        private var _top:MovieClip = null;
        private var _middle:MovieClip = null;
        private var _bottom:MovieClip = null;
        private var _barLine:MovieClip = null;
        private var _height:Number = 0;
        private var _y:Number = 0;
        private var _visible:Boolean = false;
        private var _isSelected:Boolean = false;

        public function SliderBar(_arg1:MovieClip)
		{
            LIST = ["top", "bottom", "middle", "barLine"];
            super();
            _sliderBar = _arg1;
            _sliderBar.buttonMode = true;
            _sliderBar.mouseChildren = false;
            _top = _sliderBar.top;
            _middle = _sliderBar.middle;
            _bottom = _sliderBar.bottom;
            _barLine = _sliderBar.barLine;
            showMouseEffect("out");
        }
        public function showBar():void
		{
            _sliderBar.visible = true;
            _visible = true;
            addEvent();
        }
        public function hideBar():void
		{
            _sliderBar.visible = false;
            _visible = false;
            removeEvent();
        }
        public function select(_arg1:Boolean):void
		{
            _isSelected = _arg1;
            if (_isSelected)
			{
                showMouseEffect("down");
                return;
            }
            showMouseEffect("out");
        }
        private function addEvent():void
		{
            _sliderBar.addEventListener(MouseEvent.ROLL_OVER, overHandler);
            _sliderBar.addEventListener(MouseEvent.ROLL_OUT, outHandler);
        }
        private function removeEvent():void
		{
            _sliderBar.removeEventListener(MouseEvent.ROLL_OVER, overHandler);
            _sliderBar.removeEventListener(MouseEvent.ROLL_OUT, outHandler);
        }
        private function outHandler(_arg1:MouseEvent):void
		{
            if (_isSelected)
			{
                return;
            }
            showMouseEffect("out");
        }
        private function overHandler(_arg1:MouseEvent):void
		{
            if (_isSelected)
			{
                return;
            }
            showMouseEffect("over");
        }
        private function showMouseEffect(_arg1:String):void
		{
            var _local2:int;
            while (_local2 < LIST.length) 
			{
                stopAt(this[("_" + LIST[_local2])], _arg1);
                _local2++;
            }
        }
        private function stopAt(_arg1:MovieClip, _arg2:String):void
		{
            if ((((_arg1 == null)) || ((_arg1.totalFrames == 1))))
			{
                return;
            }
            var _local3:Scene = _arg1.scenes[0];
            var _local4:Array = getFrameLabels(_local3.labels);
            if (_local4.indexOf(_arg2) == -1)
			{
                return;
            }
            _arg1.gotoAndStop(_arg2);
        }
        private function getFrameLabels(_arg1:Array):Array
		{
            var _local2:Array = [];
            var _local3:int;
            while (_local3 < _arg1.length)
			{
                _local2[_local3] = _arg1[_local3].name;
                _local3++;
            }
            return _local2;
        }
        private function adjustBar():void
		{
            _top.y = 0;
            _middle.y = (_top.y + _top.height);
            if (_barLine)
			{
                _barLine.y = (_middle.y + ((_middle.height - _barLine.height) / 2));
            }
            _bottom.y = (_middle.y + _middle.height);
        }
        public function get height():Number
		{
            return (((_top.height + _middle.height) + _bottom.height));
        }
        public function set height(_arg1:Number):void
		{
            if (_arg1 > ((_top.height + _bottom.height) + 10))
			{
                _height = _arg1;
            } else 
			{
                _height = ((_top.height + _bottom.height) + 10);
            }
            _middle.height = ((_height - _top.height) - _bottom.height);
            adjustBar();
        }
        public function get y():Number
		{
            return (_y);
        }
        public function set y(_arg1:Number):void
		{
            _y = _arg1;
            _sliderBar.y = _y;
        }
        public function get visible():Boolean
		{
            return (_visible);
        }
    }
}
